
<div style="width: 100%">
<div class="announcementsTitle"><?php  echo $text_good_request; ?></div>
 <div class="homeTabs">
 
 <?php 
 
 
 if (getParameter("send_request")!=null) {
	
 	
 	 	$sSql ="INSERT INTO `immo_goodsrequests` (`id`, `operationtypeId`, `minPrice`, `maxPrice`, `surface_min`, `surface_max`, `countryId`, `cityId`, `quartierId`, `goodtypeId`, `agencyId`, `status`, `owner`, `rooms_min`, `rooms_max`, `mobile`, `commentary`) VALUES ".
 	 		    "(NULL, '".getParameter("operationtypeId")."', '".getParameter("price_min")."','".getParameter("price_max")."', '".getParameter("surface_min")."', '".getParameter("surface_max")."', '".getParameter("countryId")."', '".getParameter("cityId")."', '".getParameter("quartierId")."', '".getParameter("goodtypeId")."', '".$agencyId."', 'N', '".getParameter("name")."', '".getParameter("rooms_min")."', '".getParameter("rooms_max")."', '".getParameter("mobile")."','".getParameter("commentary")."');";
 Portal_log($sSql);
 	 		$rs=$GLOBALS["conn"]->Execute($sSql);
 	
 		?>
 <div class="pam_title"><?php echo $text_request_sent;?></div>
 <?php
 }else{
 
 ?>

  <form action="<?php echo curPageURI();?>" method="POST">
  <input  type="hidden" name="send_request" value="true">
 <table cellspacing="0" class="ewTable">
	<tbody>
	<tr class="ewTableAltRow">
		<td class="pam_title"><?php echo $text_request_goodtype; ?><span class="ewRequired">&nbsp;*</span></td>
		<td style="border-right: 0pt none;"><span id="el_goodtypeId">
<table class="ewItemTable"><tbody><tr>

<?php
$sSql ="Select goodtype.lib_".$lang." as lib, goodtype.id From immo_goodtype goodtype ";
      $rs=$GLOBALS["conn"]->Execute($sSql); 
		
 while ( !$rs->EOF)  { 
		  ?>
<td><label><input type="checkbox"  value="<?php echo $rs->fields["id"]; ?>" title="" name="goodtypeId"><?php echo $rs->fields["lib"]; ?></label></td>
				  <?php
		  $rs->MoveNext();    
		  }


	
?>
<td>&nbsp;</td></tr></tbody></table>
</span>		</td>
	</tr>
	<tr class="ewTableRow">
		<td class="pam_title"><?php echo $text_request_operation; ?><span class="ewRequired">&nbsp;*</span></td>
		<td style="border-right: 0pt none;"><span id="el_operationtypeId">
<div class="ewTemplate" id="tp_operationtypeId"><label></label></div>

<table class="ewItemTable"><tbody><tr>
<?php
$sSql ="Select operationtype.lib_".$lang." as lib, operationtype.id From immo_operationtype operationtype ";
      $rs=$GLOBALS["conn"]->Execute($sSql); 
		
 while ( !$rs->EOF)  { 
		  ?>
<td><label><input type="radio" checked="checked" value="<?php echo $rs->fields["id"]; ?>" title="" name="operationtypeId"><?php echo $rs->fields["lib"]; ?></label></td>


				  <?php
		  $rs->MoveNext();    
		  }


	
?>
<td>&nbsp;</td></tr></tbody></table>
</span>		</td>
	</tr>
	
		<tr class="ewTableAltRow">
		<td class="pam_title"><?php echo $text_request_name; ?><span class="ewRequired">&nbsp;*</span></td>
		<td style="border-right: 0pt none;">
<input type="text" value="" size="30" title="" id="name" name="name">
	</td>
	</tr>
	<tr class="ewTableAltRow">
		<td class="pam_title"><?php echo $text_request_mobile; ?><span class="ewRequired">&nbsp;*</span></td>
		<td style="border-right: 0pt none;">
<input type="text" value="" size="30" title="" id="mobile" name="mobile">
	</td>
	</tr>
	

	<tr class="ewTableAltRow">
		<td class="pam_title" style="padding-top: 11px;"><?php echo $text_search_budget; ?></td>
		<td style="border-right: 0pt none;">

<table>
<tr>
<td>
<div id="slider-amount" style="width: 197px;"></div>
</td>
<td style="padding-top: 14px;">

	
	<input type="text" id="amount"  />

</td>

</tr>
</table>






	</td>
	</tr>
	
	<tr class="ewTableRow">
		<td class="pam_title" style="padding-top: 11px;"><?php echo $text_request_rooms; ?></td>
		<td style="border-right: 0pt none;"><span id="el_rooms">
<table>
<tr>
<td>
<div id="slider-rooms" style="width: 197px;"></div>
</td>
<td style="padding-top: 14px;">

		<input type="hidden" name="rooms_min" id="rooms_min" />
	<input type="hidden" name="rooms_max" id="rooms_max" />
	<input type="text" id="rooms"  />

</td>

</tr>
</table>
</span>		</td>
	</tr>
	
	

	
	<tr class="ewTableRow">
		<td class="pam_title" style="padding-top: 11px;"><?php echo $text_request_surface; ?></td>
		<td style="border-right: 0pt none;"><span id="el_surface">
<table>
<tr>
<td>
<div id="slider-surface" style="width: 197px;"></div>
</td>
<td style="padding-top: 14px;">

		<input type="hidden" name="surface_min" id="surface_min" />
	<input type="hidden" name="surface_max" id="surface_max" />
	<input type="text" id="surface"  />

</td>

</tr>
</table>
</span>		</td>
	</tr>


	
	<tr class="ewTableRow">
		<td class="pam_title"><?php echo $text_request_country; ?><span class="ewRequired">&nbsp;*</span></td>
		<td style="border-right: 0pt none;"><span id="el_countryId">
		
<select  title="" name="countryId" id="countryId" >
<option value="none"><?php echo $choisir; ?></option>
<?php

$sSql ="Select countries.lib_".$lt." as lib, countries.id From portal_countries countries ";
if ($international=="N") $sSql.="WHERE countries.id=".$defaultCountry;
      $rs=$GLOBALS["conn"]->Execute($sSql); 
		
 while ( !$rs->EOF)  { 
 	
		  ?>
<option  value="<?php echo $rs->fields["id"]; ?>"><?php echo $rs->fields["lib"]; ?></option>

				  <?php
		  $rs->MoveNext();    
		  }


	
?>
</select>
</span>		</td>
	</tr>
	<tr class="ewTableAltRow">
		<td class="pam_title"><?php echo $text_request_city; ?><span class="ewRequired">&nbsp;*</span></td>
		<td style="border-right: 0pt none;"><span id="el_cityId">
<select  name="cityId" id="cityId" >
<option value="0"><?php echo $choisir; ?></option>
</select>
</span>		</td>
	</tr>
	<tr class="ewTableRow">
		<td class="pam_title"><?php echo $text_request_quarter; ?><span class="ewRequired">&nbsp;*</span></td>
		<td style="border-right: 0pt none;"><span id="el_quartierId">
<select title="" name="quartierId" id="quartierId" >
<option value="0"><?php echo $choisir; ?></option>
</select>
<input type="hidden" value="Rif1MfTdAs1M1ttxTU6oWueefnFbVEmGEao4rpu5vDc80M0aibnTXydP_kWsQc7vdi4fExcoP6qmcNws74gh1zsTamrbJ_VSvedz8mOpQ6a5EdoCMy1-JL3YigH9iXG85zZnV-Zy6iu3AKoCSXHGAw.." id="s_quartierId" name="s_quartierId">
<input type="hidden" value="1" id="lft_quartierId" name="lft_quartierId">
</span>		
</td>
	</tr>
	<tr class="ewTableAltRow">
		<td class="pam_title"><?php echo $text_request_comment; ?></td>
		<td style="border-right: 0pt none;">
<textarea rows="5" cols="45" title="" id="commentary" name="commentary"></textarea>
	</td>
	</tr>


</tbody></table>
<input type="submit" value="<?php echo $text_send; ?>"> 
 
 </form>
 
 

</div></div>

<script type="text/javascript" charset="utf-8">
var fac=0;
$(function(){
  $("select#countryId").change(function(){
    $.getJSON("portlet.php",{id: $(this).val(),app:'citiesajax',language:'<?php echo $lt; ?>', ajax: 'true'}, function(data){

   	      
        var options = '<option value="0"><?php echo $choisir; ?></option>';
    for (var i = 0; i < data.length; i++) {
    	
    
        options += '<option  value="' +data[i].optionValue + '">' + data[i].optionDisplay + '</option>';
      }
      $("select#cityId").html(options);

  		 $("select#cityId").val(<?php echo $defaultCity; ?>);
    	 $("select#cityId").change();
    })
  })
})


$(function(){
  $("select#cityId").change(function(){
    $.getJSON("portlet.php",{id: $(this).val(),app:'quartiersajax',language:'<?php echo $lt; ?>', ajax: 'true'}, function(data){

   	      
        var options = '<option value="0"><?php echo $choisir; ?></option>';
    for (var i = 0; i < data.length; i++) {
        options += '<option value="' +data[i].optionValue + '">' + data[i].optionDisplay + '</option>';
      }
      $("select#quartierId").html(options);

      
    })
  })
})


	$(document).ready(function() {
 $("select#countryId").val("<?php echo $defaultCountry; ?>");
 $("select#countryId").change();
	});


	$("input[name='operationtypeId']").change(function() {
		 if ($(this).val()==2) fac=100; else 
			 if ($(this).val()==4)  fac=3; else fac=10;
		
				$( "#slider-amount" ).slider({
					range: true,
					min: 0*fac,
					max: 200*fac,
					values: [ 20*fac, 70*fac ],
					slide: function( event, ui ) {
						$( "#amount" ).val( formatCurrency(ui.values[ 0 ]*fac) + " <?php echo $text_dhs; ?> - " + formatCurrency(ui.values[ 1 ]*fac) +  " <?php echo $text_dhs; ?> "  );
						$( "#price_max" ).val(ui.values[ 1 ]*fac);
						$( "#price_min" ).val(ui.values[ 0 ]*fac);
						
					}
				});
				//
				
	});

	
	$("input[name='operationtypeId']").change();
	$( "#amount" ).val( $( "#slider-amount" ).slider( "values", 0 )*fac + " <?php echo $text_dhs; ?> - " + $( "#slider-amount" ).slider( "values", 1 )*fac+  " <?php echo $text_dhs; ?> "  );
	$( "#price_max" ).val($( "#slider-amount" ).slider( "values",1 )*fac);
	$( "#price_min" ).val($( "#slider-amount" ).slider( "values", 0 )*fac);
	
	$( "#slider-rooms" ).slider({
		range: true,
		min: 1,
		max: 10,
		values: [ 2, 5 ],
		slide: function( event, ui ) {
			$( "#rooms" ).val(ui.values[ 0 ] + " <?php echo $text_rooms; ?> - " + ui.values[ 1 ] +  " <?php echo $text_rooms; ?> "  );
			$( "#rooms_max" ).val(ui.values[ 1 ]);
			$( "#rooms_min" ).val(ui.values[ 0 ]);
		}
	});
	$( "#rooms" ).val( $( "#slider-rooms" ).slider( "values", 0 )+ " <?php echo $text_rooms; ?> - " + $( "#slider-rooms" ).slider( "values", 1 )+  " <?php echo $text_rooms; ?> "  );
	$( "#rooms_max" ).val($( "#slider-rooms" ).slider( "values", 1 ));
	$( "#rooms_min" ).val($( "#slider-rooms" ).slider( "values", 0 ));
	
	$( "#slider-surface" ).slider({
		range: true,
		min: 10,
		max: 3000,
		values: [ 600, 1500 ],
		slide: function( event, ui ) {
			$( "#surface" ).val(ui.values[ 0 ] + " <?php echo $text_surface; ?> - " + ui.values[ 1 ] +  " <?php echo $text_surface; ?> "  );
			$( "#surface_max" ).val(ui.values[ 1 ]);
			$( "#surface_min" ).val(ui.values[ 0 ]);
		}
	});
	$( "#surface" ).val( $( "#slider-surface" ).slider( "values", 0 )+ " <?php echo $text_surface; ?> - " + $( "#slider-surface" ).slider( "values", 1 )+  " <?php echo $text_surface; ?> "  );
	$( "#surface_max" ).val($( "#slider-surface" ).slider( "values", 1 ));
	$( "#surface_min" ).val($( "#slider-surface" ).slider( "values", 0 ));
	</script>
		<style>
	
	
	#amount{
	border:0; 
	width: 297px;
	padding-<?php echo $left; ?>: 10px;
 background-color: transparent;
	}
	#rooms{
	border:0; 
	width: 297px;
	padding-<?php echo $left; ?>: 10px;
 background-color: transparent;
	}
	#surface{
	border:0; 
	width: 297px;
	padding-<?php echo $left; ?>: 10px;
 background-color: transparent;
	}
	</style>
	


<?php if (ew_CurrentPage()!="portlet.php") {?>

<script  type="text/javascript">


	 tinyMCE.init({
		  mode : "textareas",
	      theme : "simple",
	      directionality :"<?php echo $dir; ?>",
	    height:"260px",
	    width:"527px"
	});



</script>
<?php } ?>

<?php }?>